# -*- coding: utf-8 -*-
# @Time : 2022/7/31 下午2:00
# @Author : WangYunfei
# @FileName: pinglun.py
# @Email: yunfei.wang@innvote.com
import re

import requests

if __name__ == '__main__':

    headers = {
        # "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
        # "accept-encoding": "gzip, deflate, br",
        # "accept-language": "zh-CN,zh;q=0.9",
        # "cache-control": "no-cache",
        # "cookie": "SESSIONID=sbdYjOrWr2zQXJBNdc46jVAxym6nxoNIHjDO6iNYosg; JOID=U1ERB0rGt1-dq0_8C8PPCJs39KQbnOoJ_vItmUW85zb1ngayNxehvPqjSvEOEPT9A7JAsPbA5y-_8RDf0ZZztN4=; osd=U1kQAU_Gv16brk_0CsXKCJM28qEblOsP-_IlmEO55z70mAOyPxanufqrS_cLEPz8BbdAuPfG4i-38Bba0Z5ysts=; _zap=e86d3057-1b2a-497b-b0aa-9219b3f58ecb; d_c0=\"APAdagipRxWPTgA7uRQGQx6SrHjS9PVbO3Y=|1658366293\"; _9755xjdesxxd_=32; YD00517437729195%3AWM_TID=0MLAjG0gtVtAQQVEVULECTQciNqa0Nvp; _xsrf=GzPiN3mi0y8ltm2WYf7BgtX7fA7xGRzA; Hm_lvt_98beee57fd2ef70ccdd5ca52b9740c49=1658902382,1658975925,1659082198,1659247244; __snaker__id=K3lh9ebknCmfQSFU; gdxidpyhxdE=NtX%2BHJW3PSSw0Kgbxpum6nLjxuJwquERRZY6CxxpqS%5CQC5t64gnOmWACGBjIGvNj1GZuHWlaP3WUvey%2Btx78EZGqcgLq28RmITNNmnS3Z0r7H1uOZxwP4ut7ODCY6my%5CwjbVPRS15BNdZvcLsWDwrIUr4TZzoBnSalkkE5Pb5m%2BR4DOC%3A1659248144897; YD00517437729195%3AWM_NIKE=9ca17ae2e6ffcda170e2e6ee9bf53aa1e8fd9bee5a868a8fb2d84a828f9e82c560919282d5ec218995a4b1ef2af0fea7c3b92aed8e9aa9ce4782a7b7bbd133afb387b7fc7e8ceb8f96f45c81ea96a8cd79f2b284aec859f590bc8ec444b586e5b6f654b1ac89b9d33aede8bfb0b250a3b7c0b4eb4492a6a9b9e960bce8a2b4b35d86ecf997c953f2ee9998b8259baff9a2ce73e99e8582cd6dadaf81d3d64a96f5a18ce465afefa3acf547a79ef99baa668d8c9fb6e637e2a3; YD00517437729195%3AWM_NI=%2FRVHOMByyZR9mmIVyvH5AuqPC6ZGNs2nLMES7PtmAHwZ%2BUwXstGXP2%2F8qO3DaipShHRzgXjTx8nS0WF47vJY22Ww5%2FYq7AOy%2BBKaNgoqO2WBV%2Bokaom1mKvMeB7z%2BnOTQUg%3D; SESSIONID=RPVfYjhNzXdh0IF1DNPsNd5BYPLj34VAzNIzaQE9Kiy; osd=Ul8TBkg_31Lfixg2AzqrBtYXo2IQao4Hv9F1X05GgDe0vVJ3M5nHsbiPHjQGcIxtlGng9BPqbet9p5oSbX7VC2w=; JOID=VVwWBks43FffiB81BjqoAdUSo2EXaYsHvNZ2Wk5FhzSxvVFwMJzHsr-MGzQFd49olGrn9xbqbux-opoRan3QC28=; _ga=GA1.2.312754850.1659247279; _gid=GA1.2.736935173.1659247279; l_n_c=1; q_c1=28b7358e9b604afba0db22406edd04c3|1659247304000|1659247304000; r_cap_id=\"OWNkZmJmYmU2M2E0NDJlZTg4MDMwMDNkNjI5YjgzMzk=|1659247303|beaa4e4d1a5c44db4f333ea112d209df0d88796e\"; cap_id=\"YTVjYTlhMjI3MzYxNDU0M2JiNjEzNWQ1Y2NiMzcxNjg=|1659247303|475e36ac484a677f6bb47e9293fee87dc77461b3\"; l_cap_id=\"ZGNjZjVlY2U4ZTM3NDhjM2E2ZTU2YjY0YTM2YzIzZjM=|1659247303|15033a2caa581275dd5dec377ba48fb61238fa1c\"; n_c=1; __utmz=51854390.1659247305.1.1.utmcsr=baidu|utmccn=(organic)|utmcmd=organic; __utmc=51854390; __utmb=51854390.0.10.1659247305; __utma=51854390.312754850.1659247279.1659247305.1659247305.1; __utmv=51854390.000--|3=entry_date=20220731=1; Hm_lpvt_98beee57fd2ef70ccdd5ca52b9740c49=1659247580; captcha_session_v2=2|1:0|10:1659247581|18:captcha_session_v2|88:NTd5WXpwZnIxdlJPbW16UWQzUkpGdldacmkySW1KMmxrTU13THhqa2k5bkhNN1BKVU0xQ0M5cGZ0cTM5d3ZZNw==|06c1b8ca04bc1b9c46998e94507eb124cd40741ffc737518a460cc10ab35d504; KLBRSID=ca494ee5d16b14b649673c122ff27291|1659248054|1659247243",
        "pragma": "no-cache",
        "sec-ch-ua": "\".Not/A)Brand\";v=\"99\", \"Google Chrome\";v=\"103\", \"Chromium\";v=\"103\"",
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": "\"Windows\"",
        # "sec-fetch-dest": "document",
        # "sec-fetch-mode": "navigate",
        # "sec-fetch-site": "none",
        # "sec-fetch-user": "?1",
        "Content-Type": "text/html; charset=UTF-8",
        "upgrade-insecure-requests": "1",
        "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"
    }

    url = "https://www.zhihu.com/question/546111363"

    # res = requests.get(url, headers=headers)
    # res.encoding = "utf-8"
    # print(res.status_code)
    # print(res.text)
    # print(res.cookies)

    # all_str = re.findall(r'"next":"(http.*?)",', res.text)
    # print(all_str)

    str_c = "https:\\u002F\\u002Fwww.zhihu.com\\u002Fapi\\u002Fv4\\u002Fquestions\\u002F546111363\\u002Ffeeds?cursor=0a77b08775b66064d688272b973b6fe1&include=data%5B%2A%5D.is_normal%2Cadmin_closed_comment%2Creward_info%2Cis_collapsed%2Cannotation_action%2Cannotation_detail%2Ccollapse_reason%2Cis_sticky%2Ccollapsed_by%2Csuggest_edit%2Ccomment_count%2Ccan_comment%2Ccontent%2Ceditable_content%2Cattachment%2Cvoteup_count%2Creshipment_settings%2Ccomment_permission%2Ccreated_time%2Cupdated_time%2Creview_info%2Crelevant_info%2Cquestion%2Cexcerpt%2Cis_labeled%2Cpaid_info%2Cpaid_info_content%2Creaction_instruction%2Crelationship.is_authorized%2Cis_author%2Cvoting%2Cis_thanked%2Cis_nothelp%2Cis_recognized%3Bdata%5B%2A%5D.mark_infos%5B%2A%5D.url%3Bdata%5B%2A%5D.author.follower_count%2Cvip_info%2Cbadge%5B%2A%5D.topics%3Bdata%5B%2A%5D.settings.table_of_content.enabled&limit=5&offset=0&order=default&platform=desktop&session_id=1659257175413599732"
    text = str_c.encode("utf-8").decode('unicode_escape')
    print(text)
    from urllib.parse import quote

    text2 = quote(text)
    print(text2)
    print(str_c)

